package o;

import android.content.Context;
import androidx.annotation.NonNull;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.gamebox.plugin.gameservice.bean.RealNameCacheInfo;
import com.huawei.gamebox.plugin.gameservice.bean.RealNameParam;
import com.huawei.gamebox.plugin.realnameauth.RealNameAuthActivity;
import org.json.JSONObject;

public class faw {
    private static faw ˎ;
    private ccm ˏ;

    public interface d {
        void ˏ(int i);
    }

    public enum e {
        PAY,
        GAME_STARTUP,
        GAME_CENTER_STARTUP
    }

    public static synchronized faw ˏ() {
        faw o_faw;
        synchronized (faw.class) {
            if (ˎ == null) {
                ˎ = new faw();
            }
            o_faw = ˎ;
        }
        return o_faw;
    }

    public void ˎ(ccm o_ccm) {
        this.ˏ = o_ccm;
    }

    public void ˎ(@NonNull Context context, @NonNull GameInfo gameInfo, @NonNull e eVar, final RealNameParam realNameParam, final d dVar) {
        boolean z = false;
        if (realNameParam == null) {
            if (Logger.ˎ()) {
                Logger.ˏ("RealNameAuthManager", "the realNameParam is null");
            }
            ˎ(dVar, 0);
        } else if (realNameParam.ॱ() == 0) {
            if (Logger.ˎ()) {
                Logger.ˏ("RealNameAuthManager", "IsShowRealName is 0");
            }
            ˎ(dVar, 0);
        } else if (context == null || gameInfo == null || eVar == null) {
            Logger.e("RealNameAuthManager", "the param is null");
            ˎ(dVar, 2);
        } else {
            if (eVar == e.GAME_STARTUP) {
                z = true;
            }
            String ˊ = this.ˏ != null ? this.ˏ.ˊ() : "";
            if (eVar == e.GAME_STARTUP || eVar == e.PAY) {
                ezq.ˏ().ˏ("game.realName.popTime", realNameParam.ˋ(), ˊ);
            } else {
                ezq.ˏ().ˏ("higame.realName.popTime", realNameParam.ˋ(), ˊ);
                ˏ(new fas(eVar, ॱ()).ˋ());
            }
            RealNameAuthActivity.ˎ(context, gameInfo, realNameParam, new fav(this) {
                final /* synthetic */ faw ˊ;

                public void ˋ(int i) {
                    this.ˊ.ˏ(i, realNameParam, dVar);
                }
            }, z);
        }
    }

    public boolean ॱ(int i) {
        return i >= 0;
    }

    private void ˏ(RealNameCacheInfo realNameCacheInfo) {
        if (realNameCacheInfo != null) {
            try {
                eyt.ॱ().ˊ(realNameCacheInfo.toJson());
            } catch (Exception e) {
                Logger.e("RealNameAuthManager", "saveReamNameAuthParams exception");
            }
        }
    }

    private RealNameCacheInfo ॱ() {
        String ˏ = eyt.ॱ().ˏ();
        if (ˏ == null) {
            return null;
        }
        RealNameCacheInfo realNameCacheInfo = new RealNameCacheInfo();
        try {
            realNameCacheInfo.fromJson(new JSONObject(ˏ));
            return realNameCacheInfo;
        } catch (Exception e) {
            Logger.e("RealNameAuthManager", "getReamNameAuthParams exception");
            return null;
        }
    }

    private void ˏ(int i, @NonNull RealNameParam realNameParam, d dVar) {
        if (realNameParam != null && realNameParam.ˏ() == 0) {
            ˎ(dVar, i);
        } else if (i == 2) {
            ˊ(dVar, i);
        } else {
            ˎ(dVar, i);
        }
    }

    private void ˎ(d dVar, int i) {
        if (dVar == null) {
            Logger.e("RealNameAuthManager", "notifyContinue the handler is null");
            return;
        }
        if (Logger.ˎ()) {
            Logger.ˏ("RealNameAuthManager", "notifyContinue, the result:" + i);
        }
        switch (i) {
            case 0:
                dVar.ˏ(0);
                return;
            case 1:
                dVar.ˏ(2);
                return;
            case 2:
                dVar.ˏ(1);
                return;
            default:
                return;
        }
    }

    private void ˊ(d dVar, int i) {
        if (dVar == null) {
            Logger.e("RealNameAuthManager", "notifyStop the handler is null");
            return;
        }
        if (Logger.ˎ()) {
            Logger.ˏ("RealNameAuthManager", "notifyStop, the result:" + i);
        }
        if (i == 2) {
            dVar.ˏ(-1);
        }
    }
}
